package com.xx.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.xx.entity.Employee;
import com.xx.mapper.EmployeeMapper;
import com.xx.service.EmployeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class EmployeeServiceImpl implements EmployeeService {

    @Autowired
    EmployeeMapper employeeMapper;

    @Override
    public PageInfo<Employee> getList(String empName, String jobTitle, Integer pageNum) {
        PageHelper.startPage(pageNum,1);
        List<Employee> employeeList = employeeMapper.getList(empName, empName);
        PageInfo<Employee> pageInfo = new PageInfo<>(employeeList);
        return pageInfo;
    }

    @Override
    public Employee getEmployeeInfo(Integer employeeId) {
        return employeeMapper.getEmployeeInfo(employeeId);
    }

    @Override
    public PageInfo<Employee> getPage(String empName, String jobTitle, Integer pageNum) {
        PageHelper.startPage(pageNum,1);
        List<Employee> employeeList = employeeMapper.getList(empName, empName);
        PageInfo<Employee> pageInfo = new PageInfo<>(employeeList);
        return pageInfo;
    }

    @Override
    public int saveEmployee(Employee employee) {
        return employeeMapper.saveEmployee(employee);
    }

    @Override
    public int updateEmployee(Employee employee) {
        return employeeMapper.updateEmployee(employee);
    }

    @Override
    public int delEmployee(Integer employeeId) {
        return employeeMapper.delEmployee(employeeId);
    }
}
